package org.agile2soft.nexoma.expedient.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.agile2soft.nexoma.core.entity.Request;

@Entity
@Table(name = "EXPEDIENT")
@SuppressWarnings({"serial"})
public class Expedient implements java.io.Serializable {

    private Integer id;
    private ExpedientType expedientType;
    private Date openDate;
    private Date closeDate;
    private boolean status;
    private String comments;
    private Set<Request> requests = new HashSet<Request>(0);
    private Set<ExpedientTypePhaseExpedients> expedientTypePhaseExpedients = new HashSet<ExpedientTypePhaseExpedients>();

    public Expedient() {
    }

    public Expedient(ExpedientType expedientType, Date openDate,
            boolean status) {
        this.expedientType = expedientType;
        this.openDate = openDate;
        this.status = status;
    }

    public Expedient(ExpedientType expedientType, Date openDate,
            Date closeDate, boolean status, String comments,
            Set<Request> requests,
            Set<ExpedientTypePhaseExpedients>expedientTypePhaseExpedients) {
        this.expedientType = expedientType;
        this.openDate = openDate;
        this.closeDate = closeDate;
        this.status = status;
        this.comments = comments;
        this.requests = requests;
        this.expedientTypePhaseExpedients = expedientTypePhaseExpedients;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "EXP_ID", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "TEX_ID", nullable = false)
    public ExpedientType getExpedientType() {
        return this.expedientType;
    }

    public void setExpedientType(ExpedientType expedientType) {
        this.expedientType = expedientType;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "EXP_OPEN_DATE", nullable = false, length = 10)
    public Date getOpenDate() {
        return this.openDate;
    }

    public void setOpenDate(Date openDate) {
        this.openDate = openDate;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "EXP_CLOSE_DATE", length = 10)
    public Date getCloseDate() {
        return this.closeDate;
    }

    public void setCloseDate(Date closeDate) {
        this.closeDate = closeDate;
    }

    @Column(name = "EXP_STATUS", nullable = false)
    public boolean isStatus() {
        return this.status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    @Column(name = "EXP_COMMENTS", length = 250)
    public String getComments() {
        return this.comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "expedient")
    public Set<Request> getRequests() {
        return this.requests;
    }

    public void setRequests(Set<Request> requests) {
        this.requests = requests;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "expedient")
    public Set<ExpedientTypePhaseExpedients> getExpedientTypePhaseExpedients() {
        return this.expedientTypePhaseExpedients;
    }

    public void setExpedientTypePhaseExpedients(Set<ExpedientTypePhaseExpedients> expedientTypePhaseExpedients) {
        this.expedientTypePhaseExpedients = expedientTypePhaseExpedients;
    }
}
